namespace Aob.Lite.Dsl

import System

import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast

class AdviceMacro(AbstractAstMacro):
"""Description of AdviceMacro"""
	
	override def Expand(macro as MacroStatement):
		AdviceMacroHelper.ValidateArgs(macro)
		block = macro.Block.CloneNode()
		block.Annotate(Annotations.Advice, AdviceInfo(macro))
		return block
		
class AdviceMacroHelper:
	
	static def ValidateArgs(macro as MacroStatement):
		for e in macro.Arguments:
			assert Validate(e), "Advice parameters must be only of type TryCastExpression or ReferenceExpression"
		
	static private def Validate(e):
		return (e isa TryCastExpression) or (e isa ReferenceExpression)

class AdviceInfo:
	
	[getter(Macro)]
	_macro as MacroStatement
	
	def constructor(macro as MacroStatement):
		_macro = macro
		

